home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13664 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: nyssa.swt.edu!LN16674
  2. From: ln16674@nyssa.swt.edu (Leland Newsom)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: reversing a string
  5. Date: 9 Apr 1996 17:38:14 GMT
  6. Organization: Southwest Texas State University
  7. Message-ID: <4ke7a6$49m@central.server.swt.edu>
  8. References: <4k6cjl$j8f@central.server.swt.edu> <4kb1s7$6eu@ibm32.perftech.com>,<829058514snz@genesis.demon.co.uk>
  9. Reply-To: ln16674@nyssa.swt.edu
  10. NNTP-Posting-Host: nyssa.swt.edu
  11.  
  12. In article <829058514snz@genesis.demon.co.uk>, Lawrence Kirby <fred@genesis.demon.co.uk> writes:
  13. >In article <4kb1s7$6eu@ibm32.perftech.com>
  14. >           murf@perftech.com "John Murphy" writes:
  15. >
  16. >>In article <4k6cjl$j8f@central.server.swt.edu>, ln16674@nyssa.swt.edu 
  17. >>says...
  18. >>>
  19. >>>I have a challenge from a friend of mine.  He wanted me to reverse a string 
  20. >>>with recursion without using any additional variables or loops.  I got mine
  21. >>>to work by using exclusive or, but I needed an additional variable.  Can 
  22. >>>someone help with this problem without using the additional variable?
  23. >>>
  24. >>>Thanks
  25. >>You can swap two variables, x and y, with the following series of exclusive 
  26. >>or's:
  27. >>        x ^= y;
  28. >>        y ^= x;
  29. >>        x ^= y;
  30. >
  31. >From what he wrote I believe Leland was already doing that. The problem is
  32. >to write the entire function without using an additional variable. It
  33. >can be done! :-)
  34. >
  35. >-- 
  36. >-----------------------------------------
  37. >Lawrence Kirby | fred@genesis.demon.co.uk
  38. >Wilts, England | 70734.126@compuserve.com
  39. >-----------------------------------------
  40.  
  41.  
  42.  
  43. Yes, I was doing that.  He said that it could be done without any extra
  44. variables.  He also said that if you get real cryptic you can do the function
  45. in one or two lines.
  46.  
  47. Thanks
  48. Leland
  49.  
  50.